#import markdown_object as mdo
from markdown_object import text,HT,title,image
#from markdown_object import setting #v+1
def explain(s:str):
    if s[0]=='#':
        #标题
        return title.obj(*s.split(' '))
    elif s[0]=='[':
        #超链接
        textend=0
        flag=True
        for i in s:
            if i==']':
                flag=False
                break
            textend+=1
        if not flag:
            return HT.obj(s[1:textend],s[textend+2:-1])
        else:
            return text.obj(s,br=False)
    elif s[0]=='!' and s[1]=='[':
        #照片
        textend=0
        flag=True
        for i in s:
            if i==']':
                flag=False
                break
            textend+=1
        if not flag:
            return image.obj(text=s[2:textend],url=s[textend+2:-2])
        else:
            return text.obj(s[0:-1],br=False)
    else:
        #文字
        if s[-1]=='\\':
            return text.obj(s[0:-1],br=True)
        else:
            return text.obj(s,br=False)
#help(mdo)
